﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using AlunoLib.Basic;
using AlunoLib.Repositorio;
using AlunoLib.Regra;

namespace AlunoService
{
    /// <summary>
    /// Summary description for Service1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    // [System.Web.Script.Services.ScriptService]
    public class Service1 : System.Web.Services.WebService
    {

        RegAluno regras = new RegAluno();

        [WebMethod]
        public void inserir(Aluno obj)
        {
            try
            {
                regras.campoVazio(obj);
                regras.campoExistente(obj);
                RepAluno.getInstancia().inserir(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        [WebMethod]
        public List<Aluno> listar()
        {
                return RepAluno.getInstancia().listar();
        }

        [WebMethod]
        public List<Aluno> Pesquisar(string nome,string matricula)
        {
                return RepAluno.getInstancia().Pesquisar(nome,matricula);
        }

        [WebMethod]
        public void alterar(Aluno obj)
        {
            try
            {
                regras.campoVazio(obj);
                regras.campoExistente(obj);
                RepAluno.getInstancia().alterar(obj);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        [WebMethod]
        public void qtdResponsavel(int matricula)
        {
            try
            {
                regras.qtdResponsavel(matricula);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}